<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
Movie[] movieList;
movieList=(Movie[])session.getAttribute("selectedMovies");
%>
<%@page import="com.beans.Movie"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript">
function display(obj,id1,id2,id3,id4,id5) {
	txt = obj.options[obj.selectedIndex].value;
	//document.getElementById(obj).style.display = 'none';
	//document.getElementById(id2).style.display = 'none';
	if ( txt.match(id1) ) {
	document.getElementById("text").style.display = 'block';
	document.getElementById("text1").style.display = 'none';
	}
	if ( txt.match(id2) || txt.match(id3) || txt.match(id4) || txt.match(id5)) {
		document.getElementById("text").style.display = 'none';
		document.getElementById("text1").style.display = 'block';
		}
	}
function validateInput()
{
var flag = true;
var mname=document.forms["searchPersonForm"]["inputstring"].value;
document.all("inputerror").innerHTML  = "";

	if (mname==null || mname=="")
	{
		document.all("inputerror").innerHTML  = "Input String must be filled out";
		flag = false;
	}
	return flag;
}
</script>
</head>
<body>
<%@ include file="header.jsp" %>
<form id="searchPersonForm" name="movieReportForm" method="POST" action="MovieReportServlet" onsubmit="return validateInput();">

<div class="inputColumn" id="createAccount"
	style="text-align: center; border: thin; margin: auto;">
<table cellpadding="2" cellspacing="1" border="0" width="100%">
	<tr>
	<th colspan="2">
	<font size="2" color="red"><sup>*</sup> Required Fields</font></th>
	</tr>
	<tr>
	<td colspan="2">
	<% String serverException = (String)request.getAttribute("ServerMessage");
					if(serverException != null){
				%><br> <label style="size: 32; color: red"><%=serverException%></label> <%} %>
	</td>
	</tr>
	<tr>
	<td>
		<table  cellpadding="2" cellspacing="1" border="1" width="65%" style="background-color: rgb(254,252,180);">
			
			
			<thead> 
			<tr>
				<td valign="top" align="left">
				<b>Search Movie By<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<select name="category" size="1" onchange="display(this,'type','1','2','3','5');">
				<option value="1" selected >Movie Name</option>
				<option value="2" >Banner</option>
				<option value="3" >Rent</option>
				<option value="type" >Type</option>
				<option value="5">ReleaseDate</option>
				</select>
				</td>
			</tr>
			</thead>
			<tbody id="text" style="display: none;">
				<tr>
				<td valign="top" align="left">
				<b>Search Movie By<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<select name="typeid" size="1" >
				<option value="Action" selected >Action</option>
				<option value="Comedy" >Comedy</option>
				<option value="Family" >Family</option>
				<option value="History" >History</option>
				<option value="Mystry">Mystry</option>
				<option value="Sci-Fi">Sci-Fi</option>
				<option value="Adventure">Adventure</option>
				<option value="Crime">Crime</option>
				<option value="Horror">Horror</option>
				<option value="Romance">Romance</option>
				</select>
				</td>

			</tr>
			</tbody>
			<tbody id="text1" style="display: block;">
			<tr>
				<td valign="top" align="left">
				<b>Enter String:<sup style="color: red">*</sup></b></td><td valign="top" align="left">
				<input type="text" name="inputstring" size="15" maxlength="50" style="background-color:#eeeeee;">
				<br><label id="inputerror" style="size: 32; color: red"></label> 
				</td>
			</tr>
			</tbody>
			</table>
	<tr>
		<td align="center" colspan="2"><input type="submit" value="Search"> </td>
	</tr>
</table>
</div>
</form>
<form id="listForm" name="listForm">
<div class ="inputColumn" id = "CartItems"  
				style="text-align: left; border: none; margin: auto;">	
				
			<table align="center" border="1" style="border-style: dashed; background-color: rgb(254,252,180);">
			<%
			if(movieList != null)
			{
			%>
				<tr>
				
				<th align="center" style="color:red" bordercolor="red">MovieName</th>
				<th align="center" style="color:red" bordercolor="red">Banner</th>
				<th align="center" style="color:red" bordercolor="red">Type</th>
				<th align="center" style="color:red" bordercolor="red">ReleaseDate</th>
				<th align="center" style="color:red" bordercolor="red">Rent</th>
				<th align="center" style="color:red" bordercolor="red">Available</th>
				<th align="center" style="color:red" bordercolor="red">IssuedMembers</th>
				</tr>
				<% 
				
				for(int i=0;i<movieList.length;i++)
				{
				%>
				<tr bordercolor="black" >
				 
				  <td bordercolor="black">
					 	<label id ="name" style="size: 25;"><%=movieList[i].getMovieName()  %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="LBanner" style="size: 25;"><%=movieList[i].getMovieBanner()  %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="cname" style="size: 25;"><%=movieList[i].getCategoryname() %> </label> 
					</td>
					<td bordercolor="black">
					 	<label id ="release" style="size: 25;"><%=movieList[i].getReleaseDate()  %></label> 
					</td>
					<td bordercolor="black">
					 	<label id ="rent" style="size: 25;"><%=movieList[i].getRent()  %></label> 
					</td>
					<td bordercolor="black">
						<label id="copy" style="size: 35;"><%=movieList[i].getAvailableCopy()   %></label>
					</td>
					<td bordercolor="black">
						<label id="issued" style="size: 35;"><%=movieList[i].getIssuedtomembers()   %></label>
					</td>
					
				</tr>
				<%
				}
				%>
				
			</table>
			
				<%			
			}
			else
			{
			%>
			<font size="4">No Records Found</font>
			<%
			}
			%>
	</div>
</form>
</body>
</html>